﻿Imports System.Windows.Forms

Public Class CudaWatcherSettings

    Private Sub CudaWatcherSettings_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        tbxCudaminerPath.Text = My.Settings.CudaMinerPath
        tbxCudaminerArgs.Text = My.Settings.CudaMinerArgs
        tbxWatchProcesses.Text = My.Settings.WatchProcesses
        Select Case My.Settings.CudaMinerVisibility
            Case CudaMinerVisibility.Normal
                rbtnNormal.Checked = True
            Case CudaMinerVisibility.Minimized
                rbtnMinimized.Checked = True
            Case CudaMinerVisibility.Hidden
                rbtnHidden.Checked = True
        End Select
        ToolTip1.SetToolTip(tbxWatchProcesses, "A comma separated list of processes which will suspend cudaminer (e.g. hl2, wow)")
    End Sub

    Public Enum CudaMinerVisibility As Integer
        Normal
        Hidden
        Minimized
    End Enum

    Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
        My.Settings.CudaMinerPath = tbxCudaminerPath.Text
        My.Settings.CudaMinerArgs = tbxCudaminerArgs.Text
        My.Settings.WatchProcesses = tbxWatchProcesses.Text
        If rbtnNormal.Checked Then
            My.Settings.CudaMinerVisibility = CudaMinerVisibility.Normal
        ElseIf rbtnMinimized.Checked Then
            My.Settings.CudaMinerVisibility = CudaMinerVisibility.Minimized
        Else
            My.Settings.CudaMinerVisibility = CudaMinerVisibility.Hidden
        End If
        My.Settings.Save()
        Me.Close()
    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click
        If My.Settings.CudaMinerPath.Length > 0 Then
            Dim cudaExe As New System.IO.FileInfo(My.Settings.CudaMinerPath)
            OpenFileDialog1.InitialDirectory = cudaExe.DirectoryName
        End If
        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            tbxCudaminerPath.Text = OpenFileDialog1.FileName
        End If
    End Sub
End Class